<?php

require_once ('Utils.class.php');
require_once ('Html.class.php');

require_once ('Ext/class.googlepr.php');
require_once ('Ext/class.alexapr.php');
require_once ('Ext/class.bingidx.php');
require_once ('Ext/class.yahooidx.php');

define ('FILENAME', 'download.txt');

$url = 'http://' . $argv[1];

echo Alexa::getNLinkin($argv[1]);
//var_dump(Alexa::getLinkin($argv[1]));
exit;

$yahoo = new YahooPr();
$yahoo->yahooIndexed($argv[1], 'windows');
exit;


$bing = new BingPr();
/*
var_dump($bing->bingrank('windows', $argv[1]));
exit;
*/
$bing->bingIndexed($argv[1]);
exit;


$ch = curl_init($url);
$fp = fopen(FILENAME, "w");

curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);

curl_exec($ch);
curl_close($ch);
fclose($fp);

$file = fopen("download.txt", "r");

echo "IP ADDRESS: " . Utils::getIp($argv[1]) . "\n";

echo "RESPONSE: " . var_dump(Utils::getHeaderResponse($argv[1])) . "\n";

//echo "USER AGENT: " . Utils::getUserAgent() . "\n";

echo "ROBOTS: " . var_dump(Utils::robots_allowed($argv[1])) . "\n";

echo "ROBOTS CONTENT: " . Utils::getRobots($argv[1]) . "\n";

echo "SITEMAP: " . var_dump(Utils::checkSitemap($argv[1])) . "\n";

echo "SITEMAP CONTENT: " . Utils::getSitemap($argv[1]) . "\n";

exit;


$header = new Html($file);
echo "TITLE: " . $header->getTitle() . "\n";
$meta = $header->getMeta('keywords');
echo "KEYWORDS: " . $meta . "\n";

$text = $header->getText();
//echo "TEXT: " . $text . "\n";

//echo "KEYWORD DENSITY: " . Utils::keywordDensityCalculator('voip', $text) . "\n";


$gpr = new GooglePR();

/********************************************
*
* Set Options
*
********************************************/
//Override user agent
//Default : "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021204";
//$gpr->userAgent = $_SERVER["HTTP_USER_AGENT"];

//Override cache directory
//You must permissions to create directories and files in cache directory
//Default : "/tmp";
$gpr->cacheDir = dirname(__FILE__)."/prcache";

//Override maximum cache age (in seconds)
//Cache file will be expired in $maxCacheAge seconds
//Default : 86400;
$gpr->maxCacheAge = 86400;

//Enable cache support
//if true, cache option is enabled
//Default : false
$gpr->useCache = false;

//Turn debugging on
//Default : false;
$gpr->debug = true;


echo "PageRank : " .$gpr->GetPR("http://www.voipista.com/") ."\n";


/********************************************
*
* Debug query
*
********************************************/
echo "<pre>";
print_r($gpr->debugResult);
echo "</pre>"; 


$domain = 'www.voipista.com';
try {
    $Alexa = new Alexa($domain);
    $alexa_ranking = $Alexa->getAlexaRank();
    if ($alexa_ranking) {
        echo '"'.$domain.'" has Alexa ranking: ' . $alexa_ranking;
    } else {
        echo 'bla bla bla... Goodbye this cruel world!';
    }
} catch (Exception $e) {
    echo 'Error: ' . $e->getMessage() . "\n";
}





